from selenium import webdriver
from time import  sleep

bro = webdriver.Chrome(executable_path='./chromedriver.exe')

#让浏览器发起一个指定url对应请求
bro.get('http://www.taobao.com')
#获取浏览器当前页面源码数据
page_text = bro.page_source
#标签定位
search_input = bro.find_element_by_id('q')
#标签交互
search_input.send_keys('Iphone')

#执行一组js程序
bro.execute_script('window.scrollTo(0,document.body.scrollHeight)')
#点击搜索按钮
btn = bro.find_element_by_css_selector('.btn-search')
btn.click()

bro.get('https://www.baidu.com')
sleep(2)
#回退
bro.back()
#前进
bro.forward()
sleep(5)
bro.quit()